<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>用户订单管理管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function addRow(list, idx, tpl, row){
			$(list).append(Mustache.render(tpl, {
				idx: idx, delBtn: true, row: row
			}));
			$(list+idx).find("select").each(function(){
				$(this).val($(this).attr("data-value"));
			});
			$(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
				var ss = $(this).attr("data-value").split(',');
				for (var i=0; i<ss.length; i++){
					if($(this).val() == ss[i]){
						$(this).attr("checked","checked");
					}
				}
			});
		}
		function delRow(obj, prefix){
			var id = $(prefix+"_id");
			var delFlag = $(prefix+"_delFlag");
			if (id.val() == ""){
				$(obj).parent().parent().remove();
			}else if(delFlag.val() == "0"){
				delFlag.val("1");
				$(obj).html("&divide;").attr("title", "撤销删除");
				$(obj).parent().parent().addClass("error");
			}else if(delFlag.val() == "1"){
				delFlag.val("0");
				$(obj).html("&times;").attr("title", "删除");
				$(obj).parent().parent().removeClass("error");
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/shop/order/hkShopUserOrder/">用户订单管理列表</a></li>
		<li class="active"><a href="${ctx}/shop/order/hkShopUserOrder/form?id=${hkShopUserOrder.id}">用户订单管理<shiro:hasPermission name="shop:order:hkShopUserOrder:edit">${not empty hkShopUserOrder.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="shop:order:hkShopUserOrder:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="hkShopUserOrder" action="${ctx}/shop/order/hkShopUserOrder/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="addressid"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">订单号：</label>
			<div class="controls">
				<form:input path="ordernumber" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">产品乐币：</label>
			<div class="controls">
				<form:input path="productIntegral" htmlEscape="false" maxlength="11" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">支付时间：</label>
			<div class="controls">
				<input name="paytime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${hkShopUserOrder.paytime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">快递乐币：</label>
			<div class="controls">
				<form:input path="freightIntegral" htmlEscape="false" maxlength="11" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">乐币：</label>
			<div class="controls">
				<form:input path="integral" htmlEscape="false" maxlength="11" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">自媒体商户id：</label>
			<div class="controls">
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">支付类型：</label>
			<div class="controls">
				<form:input path="paytype" htmlEscape="false" maxlength="50" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">订单状态：</label>
			<div class="controls">
				<form:select path="state" class="input-xlarge ">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('hk_shop_order_state')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">售出时间：</label>
			<div class="controls">
				<input name="selltime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${hkShopUserOrder.selltime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">限制时间：</label>
			<div class="controls">
				<input name="limittime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${hkShopUserOrder.limittime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">售后状态：</label>
			<div class="controls">
				<form:select path="afterstate" class="input-xlarge ">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('hk_shop_order_afterState')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">成交时间：</label>
			<div class="controls">
				<input name="confirmdate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${hkShopUserOrder.confirmdate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">用户：</label>
			<div class="controls">
				<sys:treeselect id="user" name="user.id" value="${hkShopUserOrder.user.id}" labelName="user.name" labelValue="${hkShopUserOrder.user.name}"
					title="用户" url="/sys/office/treeData?type=3" cssClass="" allowClear="true" notAllowSelectParent="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="100" class="input-xxlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">收货人：</label>
			<div class="controls">
				<form:input path="consignee" htmlEscape="false" maxlength="100" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">手机号：</label>
			<div class="controls">
				<form:input path="phone" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">地址：</label>
			<div class="controls">
				<form:input path="address" htmlEscape="false" maxlength="200" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">省：</label>
			<div class="controls">
				<sys:treeselect id="province" name="province.id" value="${hkShopUserOrder.province.id}" labelName="province.name" labelValue="${hkShopUserOrder.province.name}"
								title="区域" url="/sys/area/treeData" cssClass="" allowClear="true" notAllowSelectParent="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">市：</label>
			<div class="controls">
				<sys:treeselect id="city" name="city.id" value="${hkShopUserOrder.city.id}" labelName="city.name" labelValue="${hkShopUserOrder.city.name}"
								title="区域" url="/sys/area/treeData" cssClass="" allowClear="true" notAllowSelectParent="true"/>

			</div>
		</div>
		<div class="control-group">
			<label class="control-label">区：</label>
			<div class="controls">
				<sys:treeselect id="area" name="area.id" value="${hkShopUserOrder.area.id}" labelName="area.name" labelValue="${hkShopUserOrder.area.name}"
								title="区域" url="/sys/area/treeData" cssClass="" allowClear="true" notAllowSelectParent="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">关闭订单原因：</label>
			<div class="controls">
				<form:input path="reason" htmlEscape="false" maxlength="200" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">快递公司：</label>
			<div class="controls">
				<form:input path="courier" htmlEscape="false" maxlength="50" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">快递单号：</label>
			<div class="controls">
				<form:input path="couriernumber" htmlEscape="false" maxlength="50" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">发货时间：</label>
			<div class="controls">
				<input name="delivertime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${hkShopUserOrder.delivertime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
			<div class="control-group">
				<label class="control-label">乐购用户订单详情：</label>
				<div class="controls">
					<table id="contentTable" class="table table-striped table-bordered table-condensed">
						<thead>
							<tr>
								<th class="hide"></th>
								<th>商品名称</th>
								<th>图片路径</th>
								<th>乐币</th>
								<th>活动类型</th>
								<th>活动乐币</th>
								<th>数量</th>
								<th>颜色</th>
								<th>规格</th>
								<%--<th>自媒体商户id</th>--%>
								<th>是否加入储物箱</th>

								<th>备注</th>
								<shiro:hasPermission name="shop:order:hkShopUserOrder:edit"><th width="10">&nbsp;</th></shiro:hasPermission>
							</tr>
						</thead>
						<tbody id="hkShopUserOrderDetailList">
						</tbody>
						<shiro:hasPermission name="shop:order:hkShopUserOrder:edit"><tfoot>
							<tr><td colspan="18"><a href="javascript:" onclick="addRow('#hkShopUserOrderDetailList', hkShopUserOrderDetailRowIdx, hkShopUserOrderDetailTpl);hkShopUserOrderDetailRowIdx = hkShopUserOrderDetailRowIdx + 1;" class="btn">新增</a></td></tr>
						</tfoot></shiro:hasPermission>
					</table>
					<script type="text/template" id="hkShopUserOrderDetailTpl">//<!--
						<tr id="hkShopUserOrderDetailList{{idx}}">
							<td class="hide">
								<input id="hkShopUserOrderDetailList{{idx}}_id" name="hkShopUserOrderDetailList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
								<input id="hkShopUserOrderDetailList{{idx}}_delFlag" name="hkShopUserOrderDetailList[{{idx}}].delFlag" type="hidden" value="0"/>
								<input id="hkShopUserOrderDetailList{{idx}}_skuId" name="hkShopUserOrderDetailList[{{idx}}].skuId" type="hidden" value="{{row.skuId}}"/>
								<input id="hkShopUserOrderDetailList{{idx}}_productId" name="hkShopUserOrderDetailList[{{idx}}].productId" type="hidden" value="{{row.productId}}"/>
							</td>
							<td>
								<input id="hkShopUserOrderDetailList{{idx}}_title" name="hkShopUserOrderDetailList[{{idx}}].title" type="text" value="{{row.title}}" maxlength="32" class="input-small "/>
							</td>

							<td>
							    <img src="{{row.imgSrc}}" width="60px"/>
							</td>
							<td>
								<input id="hkShopUserOrderDetailList{{idx}}_integral" name="hkShopUserOrderDetailList[{{idx}}].integral" type="text" value="{{row.integral}}" maxlength="11" class="input-small "/>
							</td>
							<td>
								<select id="hkShopUserOrderDetailList{{idx}}_activityType" name="hkShopUserOrderDetailList[{{idx}}].activityType" data-value="{{row.activityType}}" class="input-small ">
									<option value="">无</option>
									<c:forEach items="${fns:getDictList('hk_shop_activity_type')}" var="dict">
										<option value="${dict.value}">${dict.label}</option>
									</c:forEach>
								</select>
							</td>
							<td>
								<input id="hkShopUserOrderDetailList{{idx}}_activityPrice" name="hkShopUserOrderDetailList[{{idx}}].activityPrice" type="text" value="{{row.activityPrice}}" maxlength="11" class="input-small "/>
							</td>

							<td>
								<input id="hkShopUserOrderDetailList{{idx}}_number" name="hkShopUserOrderDetailList[{{idx}}].number" type="text" value="{{row.number}}" maxlength="11" class="input-small "/>
							</td>
							<td>
								<input id="hkShopUserOrderDetailList{{idx}}_colorname" name="hkShopUserOrderDetailList[{{idx}}].colorname" type="text" value="{{row.colorname}}" maxlength="100" class="input-small "/>
							</td>
							<td>
								<input id="hkShopUserOrderDetailList{{idx}}_specname" name="hkShopUserOrderDetailList[{{idx}}].specname" type="text" value="{{row.specname}}" maxlength="100" class="input-small "/>
							</td>

							<td>
								<select id="hkShopUserOrderDetailList{{idx}}_isstorage" name="hkShopUserOrderDetailList[{{idx}}].isstorage" data-value="{{row.isstorage}}" class="input-small ">
									<option value=""></option>
									<c:forEach items="${fns:getDictList('yes_no')}" var="dict">
										<option value="${dict.value}">${dict.label}</option>
									</c:forEach>
								</select>
							</td>

							<td>
								<textarea id="hkShopUserOrderDetailList{{idx}}_remarks" name="hkShopUserOrderDetailList[{{idx}}].remarks" rows="4" maxlength="100" class="input-small ">{{row.remarks}}</textarea>
							</td>
							<shiro:hasPermission name="shop:order:hkShopUserOrder:edit"><td class="text-center" width="10">
								{{#delBtn}}<span class="close" onclick="delRow(this, '#hkShopUserOrderDetailList{{idx}}')" title="删除">&times;</span>{{/delBtn}}
							</td></shiro:hasPermission>
						</tr>//-->
					</script>
					<script type="text/javascript">
						var hkShopUserOrderDetailRowIdx = 0, hkShopUserOrderDetailTpl = $("#hkShopUserOrderDetailTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
						$(document).ready(function() {
							var data = ${fns:toJson(hkShopUserOrder.hkShopUserOrderDetailList)};
							for (var i=0; i<data.length; i++){
								addRow('#hkShopUserOrderDetailList', hkShopUserOrderDetailRowIdx, hkShopUserOrderDetailTpl, data[i]);
								hkShopUserOrderDetailRowIdx = hkShopUserOrderDetailRowIdx + 1;
							}
						});
					</script>
				</div>
			</div>
		<div class="form-actions">
			<shiro:hasPermission name="shop:order:hkShopUserOrder:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>